package models

import (
	"3rd/mongo"
	"gopkg.in/mgo.v2"
	goerrors "github.com/go-errors/errors"
	"time"
)

type Feedback struct {
	Qid     string `bson:"qid" json:"qid"`
	Words   string `bson:"words" json:"words" valid:"Required"`
	Created int64  `bson:"created" json:"created" `
}

func AddFeedback(qid, words string) error {
	return mongo.DO(db_feedback, col_feedback, func(c *mgo.Collection) (err error) {
		if err := c.Insert(Feedback{Qid: qid, Words: words, Created: time.Now().Unix()});
		err != nil {
			return goerrors.New(err)
		}
		return nil
	})
}
